﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace BreukADO
{
    public partial class ToonResultatenOpdracht : Form
    {
        private int currentOpdrachtID;
        public ToonResultatenOpdracht()
        {
            InitializeComponent();
        }
        public int CurrentOpdrachtID
        {
            get { return currentOpdrachtID; }
            set { currentOpdrachtID = value; }
        }

        private void ToonResultatenOpdracht_Load(object sender, EventArgs e)
        {
            DataTable dt = leerlingOpdrachtTableAdapter.GetGemaakteOpdrachtenMetLeerling(currentOpdrachtID);
            dt.Columns["opdrachtID"].ColumnMapping = MappingType.Hidden;
            //dt.Columns["leerlingID"].ColumnMapping = MappingType.Hidden;
            dt.Columns["leerlingOpdrachtID"].ColumnMapping = MappingType.Hidden;

            //dt.Columns["maxScore"].ColumnMapping = MappingType.Hidden;

            //MessageBox.Show(dt.Rows.Count + " loopie");

            //for (int i = 0; i < dt.Rows.Count; i++)
            //{
            //    MessageBox.Show(dt.Rows[i]["opdrachtID"].ToString() + "" + dt.Rows[i]["leerlingID"].ToString());
            //    try
            //    {
            //        DataTable temp = leerlingOpdrachtTableAdapter.GetScore(Int32.Parse(dt.Rows[i]["opdrachtID"].ToString()), Int32.Parse(dt.Rows[i]["leerlingID"].ToString()));

            //    dt.Rows[i]["Score"] = temp.Rows[0][0].ToString();
                
            //    MessageBox.Show(temp.Rows[0][0].ToString());
            //    }
            //    catch (Exception) { }
            //}
            dataGridView2.DataSource = dt;
            


        }

        private void leerlingOpdrachtBindingSource_CurrentChanged(object sender, EventArgs e)
        {

        }

        private void dataGridView2_SelectionChanged(object sender, EventArgs e)
        {
            if (dataGridView2.SelectedRows.Count > 0)
            {

                    int llnid = Int32.Parse(dataGridView2.SelectedRows[0].Cells["leerlingID"].Value.ToString());

                    DataTable dt2=null;
                    try
                    {
                         dt2 = leerlingOpdrachtTableAdapter.GetAntwoorden(currentOpdrachtID, llnid);
                    }
                    catch (Exception )
                    {
                    }
                    
                    dt2.Columns["opdrachtID"].ColumnMapping = MappingType.Hidden;
                    dt2.Columns["leerlingID"].ColumnMapping = MappingType.Hidden;
                    dt2.Columns["leerlingOpdrachtID"].ColumnMapping = MappingType.Hidden;
                    dt2.Columns["leerlingOpdrachtDetailID"].ColumnMapping = MappingType.Hidden;
                    dt2.Columns["opdrachtDetailID"].ColumnMapping = MappingType.Hidden;
                    //dt2.Columns["maxScore"].ColumnMapping = MappingType.Hidden;

                    dataGridView3.DataSource = dt2;
                    
                    
            }
        }





    }
}
